import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../../../service/HttpsClient.dart';

class RegisterStepOneController extends GetxController {
  //TODO: Implement RegisterStepOneController
  HttpsClient httpsClient = HttpsClient();
  TextEditingController textEditingController = TextEditingController();

  @override
  void onInit() {
    super.onInit();
  }

  // 发送验证码
  Future<bool> sendCode(String tel) async {
    var response = await httpsClient.post('api/sendCode', data: {'tel': tel});
    print(response);
    if (response != null) {
      if (response['success'] == true) {
        // 测试期间，避免手动输入验证码，正式环境下不需要这行代码也可以粘贴
        Clipboard.setData(ClipboardData(text: response['code']));
        return true;
      }
      Get.snackbar('提示', response['message']);
      return false;
    }
    return false;
  }

  @override
  void onClose() {
    super.onClose();
  }
}
